class Solution {
 public:
  int hash[210];//前100存-100 后一百存 -100 也就是说存在+100的下标中
  ListNode* deleteDuplicates(ListNode* head) {
    if (head == nullptr || head->next == nullptr) return head;
    ListNode* cur = head;
    int sum = 0;
    //存进hash里面了
    while (cur) {
      hash[cur->val + 100] ++;
      cur = cur->next;
    }
    cur = head;
    for (int i = 0; i < 210; ++i) {
      if (hash[i] == 1) {
        cur->val = i - 100;
        cur = cur->next;
        sum++;
      }
    }
    if(sum == 0)
    return nullptr;
    cur = head;
    for (int i = 1; i < sum; ++i) {
      cur = cur->next;
    }
    cur->next = nullptr;
    return head;
  }
};
